package top.cluski.feieprint.web;

import com.alibaba.fastjson2.JSONObject;
import jakarta.annotation.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import top.cluski.feieprint.domain.RespVO;
import top.cluski.feieprint.domain.dto.WuliaoListenerDTO;
import top.cluski.feieprint.service.TeableService;

import java.util.Optional;

@RestController
@RequestMapping("/teable")
public class TeableController {
    @Resource
    TeableService teableService;

    @GetMapping("/record")
    public RespVO<JSONObject> getRecord() {
        return RespVO.success(teableService.getRecord());
    }

    @PostMapping("/wuliao_listener")
    public ResponseEntity<String> wuliaoListener(@RequestBody WuliaoListenerDTO wuliaoListenerDTO) {
        teableService.wuliaoListener(wuliaoListenerDTO);
        return ResponseEntity.of(Optional.empty());
    }
}
